<template>
  <view class="page_diy_table page_dormitory_information_table" :style="{ paddingTop: vuex_custom_bar_height + 'px' }">
    <tn-nav-bar>宿舍信息列表</tn-nav-bar>
    <view class="page-list" id="page_diy_table">
      <!-- 筛选模块(开始) -->
      <view class="search-wrap">
        <!-- 搜索栏 -->
        <uni-forms :modelValue="query" labelWidth="70px">
            <uni-forms-item label="宿舍名称" name="dormitory_name">
                <uni-easyinput type="text" v-model="query.dormitory_name" placeholder="宿舍名称" />
              </uni-forms-item>
              <uni-forms-item label="宿管姓名" name="name_of_dormitory_manager">
                <uni-easyinput type="text" v-model="query.name_of_dormitory_manager" placeholder="宿管姓名" />
              </uni-forms-item>
                    </uni-forms>
        <!-- /搜索栏 -->
        <view class="search-btn-wrap">
          <view class="me-btn btn-reset" @click="reset()"> 重置 </view>
          <view class="me-btn btn-search" @click="search_()"> 查询 </view>
        </view>
		<view class="toolbar">
				  <view width="100%" class="me-btn btn-add" @click="$navTo('/pagesC/dormitory_information/view?')" v-if="$check_action('/dormitory_information/table', 'add') || $check_action('/dormitory_information/view', 'add')">添加</view>
				</view>
      </view>
      <!-- 列表 -->
      <view class="list-wrap-row">
        <view v-for="(o, i) in list" :key="i" class="list-item">
          <view class="item-row " v-if="1 && $check_field('get','dormitory_name')">
            <view class="label" v-if="true">
              <span>宿舍名称</span>
            </view>
              <view class="value">
              <span>{{ o['dormitory_name'] }}</span>
            </view>
            </view>
          <view class="item-row " v-if="1 && $check_field('get','name_of_dormitory_manager')">
            <view class="label" v-if="true">
              <span>宿管姓名</span>
            </view>
              <view class="value">
              <span>{{ o['name_of_dormitory_manager'] }}</span>
            </view>
            </view>
          <!-- <view class="item-row " v-if="1 && $check_field('get','dormitory_location')">
            <view class="label" v-if="true">
              <span>宿舍位置</span>
            </view>
              <view class="value">
              <span>{{ o['dormitory_location'] }}</span>
            </view>
            </view> -->
          <view class="item-row diy-image" v-if="1 && $check_field('get','cover_photo')">
            <view class="label" v-if=" false">
              <span>封面图片</span>
            </view>
              <view class="value diy_img">
              <image :src="$fullImgUrl(o['cover_photo'])" width="100%" height="100" />
            </view>
            </view>
          <view class="item-row " v-if="0 && $check_field('get','dormitory_building')">
            <view class="label" v-if="true">
              <span>宿舍楼栋</span>
            </view>
              <view class="value">
              <span>{{ o['dormitory_building'] }}</span>
            </view>
            </view>
          <view class="item-row " v-if="0 && $check_field('get','number_of_residents')">
            <view class="label" v-if="true">
              <span>居住人数</span>
            </view>
              <view class="value">
              <span>{{ o['number_of_residents'] }}</span>
            </view>
            </view>
          <!-- <view class="item-row " v-if="0 && $check_field('get','dormitory_details')">
            <view class="label" v-if="true">
              <span>宿舍详情</span>
            </view>
              <view class="value">
              <span>{{ o['dormitory_details'] }}</span>
            </view>
            </view> -->
          <view class="content">
            <view class="item-row">
              <view class="value">点赞数{{ o['praise_len'] }}</view>
            </view>
            <view class="item-row">
              <view class="value">点击数{{ o['hits'] }}</view>
            </view>
          </view>
          <view class="operate-bar">
            <view width="100%" class="me-btn btn-delete" @click="delInfo(i)"
                  v-if="$check_action('/dormitory_information/table', 'del') || $check_action('/dormitory_information/view', 'del')">
              删除
            </view>
            <view width="100%" class="me-btn btn-info" @click="$navTo('/pagesC/dormitory_information/view?' + field + '=' + o[field])"
                  v-if="$check_action('/dormitory_information/table', 'set') || $check_action('/dormitory_information/view', 'set') || $check_action('/dormitory_information/view', 'get')">
              详情
            </view>
          </view>
        </view>
      </view>
      <!-- /列表 -->
      <!-- 分页器 -->
      <uni-pagination
        class="pager"
        show-icon="true"
        :total="count"
        :pageSize="query.size"
        :current="query.page"
        @change="page_change"
      ></uni-pagination>
      <!-- /分页器 -->
    </view>
  </view>
</template>
<script>
import mixin from '@/libs/mixins/page.js';

export default {
  mixins: [mixin],
  data() {
    return {
      // 获取数据地址
      url_get_list: '~/api/dormitory_information/get_list?like=0',
      url_del: '~/api/dormitory_information/del',

      // 字段ID
      field: 'dormitory_information_id',

      // 查询
      query: {
        size: 7,
        page: 1,
              dormitory_name: "",
                    name_of_dormitory_manager: "",
                        login_time: '',
        create_time: '',
      },

      // 数据
      list: [],
                                };
  },
  methods: {
    search_() {
      this.query.page = 1;
      this.get_list();
    },
    /**
     * 重置
     */
    reset: function reset() {
      uni.clear(this.query);
      uni.push(this.query, this.config);
      this.get_list();
    },
    delInfo(v) {
      let _this = this;
      uni.showModal({
        title: '删除',
        content: '此操作将永久删除该文件, 是否继续?',
        success: function (res) {
          if (res.confirm) {
            let list = [v];
            _this.delAll(list);
          } else if (res.cancel) {
            console.log('用户点击取消');
          }
        },
      });
    },
                                            },
  created() {
                              },
};
</script>

<style lang="scss" scoped>
  @import '@/styles/pagesC/index.scss';
</style>